/**
 * <copyright>
 * </copyright>
 *

 */
package ms.unicorn.language.languagedef.impl;

import java.util.Collection;

import ms.unicorn.language.languagedef.LabelSourceField;
import ms.unicorn.language.languagedef.LabelViewDef;
import ms.unicorn.language.languagedef.LanguagedefPackage;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.common.util.EList;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;

import org.eclipse.emf.ecore.util.EObjectContainmentEList;
import org.eclipse.emf.ecore.util.InternalEList;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Label View Def</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link ms.unicorn.language.languagedef.impl.LabelViewDefImpl#getViewFields <em>View Fields</em>}</li>
 *   <li>{@link ms.unicorn.language.languagedef.impl.LabelViewDefImpl#getViewPattern <em>View Pattern</em>}</li>
 *   <li>{@link ms.unicorn.language.languagedef.impl.LabelViewDefImpl#getEditFields <em>Edit Fields</em>}</li>
 *   <li>{@link ms.unicorn.language.languagedef.impl.LabelViewDefImpl#getEditPattern <em>Edit Pattern</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class LabelViewDefImpl extends ViewDefImpl implements LabelViewDef
{
  /**
   * The cached value of the '{@link #getViewFields() <em>View Fields</em>}' containment reference list.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getViewFields()
   * @generated
   * @ordered
   */
  protected EList<LabelSourceField> viewFields;

  /**
   * The default value of the '{@link #getViewPattern() <em>View Pattern</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getViewPattern()
   * @generated
   * @ordered
   */
  protected static final String VIEW_PATTERN_EDEFAULT = null;

  /**
   * The cached value of the '{@link #getViewPattern() <em>View Pattern</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getViewPattern()
   * @generated
   * @ordered
   */
  protected String viewPattern = VIEW_PATTERN_EDEFAULT;

  /**
   * The cached value of the '{@link #getEditFields() <em>Edit Fields</em>}' containment reference list.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getEditFields()
   * @generated
   * @ordered
   */
  protected EList<LabelSourceField> editFields;

  /**
   * The default value of the '{@link #getEditPattern() <em>Edit Pattern</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getEditPattern()
   * @generated
   * @ordered
   */
  protected static final String EDIT_PATTERN_EDEFAULT = null;

  /**
   * The cached value of the '{@link #getEditPattern() <em>Edit Pattern</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getEditPattern()
   * @generated
   * @ordered
   */
  protected String editPattern = EDIT_PATTERN_EDEFAULT;

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  protected LabelViewDefImpl()
  {
    super();
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  protected EClass eStaticClass()
  {
    return LanguagedefPackage.Literals.LABEL_VIEW_DEF;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public EList<LabelSourceField> getViewFields()
  {
    if (viewFields == null)
    {
      viewFields = new EObjectContainmentEList<LabelSourceField>(LabelSourceField.class, this, LanguagedefPackage.LABEL_VIEW_DEF__VIEW_FIELDS);
    }
    return viewFields;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public String getViewPattern()
  {
    return viewPattern;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setViewPattern(String newViewPattern)
  {
    String oldViewPattern = viewPattern;
    viewPattern = newViewPattern;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, LanguagedefPackage.LABEL_VIEW_DEF__VIEW_PATTERN, oldViewPattern, viewPattern));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public EList<LabelSourceField> getEditFields()
  {
    if (editFields == null)
    {
      editFields = new EObjectContainmentEList<LabelSourceField>(LabelSourceField.class, this, LanguagedefPackage.LABEL_VIEW_DEF__EDIT_FIELDS);
    }
    return editFields;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public String getEditPattern()
  {
    return editPattern;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setEditPattern(String newEditPattern)
  {
    String oldEditPattern = editPattern;
    editPattern = newEditPattern;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, LanguagedefPackage.LABEL_VIEW_DEF__EDIT_PATTERN, oldEditPattern, editPattern));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs)
  {
    switch (featureID)
    {
      case LanguagedefPackage.LABEL_VIEW_DEF__VIEW_FIELDS:
        return ((InternalEList<?>)getViewFields()).basicRemove(otherEnd, msgs);
      case LanguagedefPackage.LABEL_VIEW_DEF__EDIT_FIELDS:
        return ((InternalEList<?>)getEditFields()).basicRemove(otherEnd, msgs);
    }
    return super.eInverseRemove(otherEnd, featureID, msgs);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public Object eGet(int featureID, boolean resolve, boolean coreType)
  {
    switch (featureID)
    {
      case LanguagedefPackage.LABEL_VIEW_DEF__VIEW_FIELDS:
        return getViewFields();
      case LanguagedefPackage.LABEL_VIEW_DEF__VIEW_PATTERN:
        return getViewPattern();
      case LanguagedefPackage.LABEL_VIEW_DEF__EDIT_FIELDS:
        return getEditFields();
      case LanguagedefPackage.LABEL_VIEW_DEF__EDIT_PATTERN:
        return getEditPattern();
    }
    return super.eGet(featureID, resolve, coreType);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @SuppressWarnings("unchecked")
  @Override
  public void eSet(int featureID, Object newValue)
  {
    switch (featureID)
    {
      case LanguagedefPackage.LABEL_VIEW_DEF__VIEW_FIELDS:
        getViewFields().clear();
        getViewFields().addAll((Collection<? extends LabelSourceField>)newValue);
        return;
      case LanguagedefPackage.LABEL_VIEW_DEF__VIEW_PATTERN:
        setViewPattern((String)newValue);
        return;
      case LanguagedefPackage.LABEL_VIEW_DEF__EDIT_FIELDS:
        getEditFields().clear();
        getEditFields().addAll((Collection<? extends LabelSourceField>)newValue);
        return;
      case LanguagedefPackage.LABEL_VIEW_DEF__EDIT_PATTERN:
        setEditPattern((String)newValue);
        return;
    }
    super.eSet(featureID, newValue);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eUnset(int featureID)
  {
    switch (featureID)
    {
      case LanguagedefPackage.LABEL_VIEW_DEF__VIEW_FIELDS:
        getViewFields().clear();
        return;
      case LanguagedefPackage.LABEL_VIEW_DEF__VIEW_PATTERN:
        setViewPattern(VIEW_PATTERN_EDEFAULT);
        return;
      case LanguagedefPackage.LABEL_VIEW_DEF__EDIT_FIELDS:
        getEditFields().clear();
        return;
      case LanguagedefPackage.LABEL_VIEW_DEF__EDIT_PATTERN:
        setEditPattern(EDIT_PATTERN_EDEFAULT);
        return;
    }
    super.eUnset(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public boolean eIsSet(int featureID)
  {
    switch (featureID)
    {
      case LanguagedefPackage.LABEL_VIEW_DEF__VIEW_FIELDS:
        return viewFields != null && !viewFields.isEmpty();
      case LanguagedefPackage.LABEL_VIEW_DEF__VIEW_PATTERN:
        return VIEW_PATTERN_EDEFAULT == null ? viewPattern != null : !VIEW_PATTERN_EDEFAULT.equals(viewPattern);
      case LanguagedefPackage.LABEL_VIEW_DEF__EDIT_FIELDS:
        return editFields != null && !editFields.isEmpty();
      case LanguagedefPackage.LABEL_VIEW_DEF__EDIT_PATTERN:
        return EDIT_PATTERN_EDEFAULT == null ? editPattern != null : !EDIT_PATTERN_EDEFAULT.equals(editPattern);
    }
    return super.eIsSet(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public String toString()
  {
    if (eIsProxy()) return super.toString();

    StringBuffer result = new StringBuffer(super.toString());
    result.append(" (viewPattern: ");
    result.append(viewPattern);
    result.append(", editPattern: ");
    result.append(editPattern);
    result.append(')');
    return result.toString();
  }

} //LabelViewDefImpl
